/*
  Programa Wifis, 2010-2011
  Autor: Nilhcraiv

This file is part of Wifis.

    Wifis is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Wifis is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Wifis.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "dialogo.h"
#include "ui_dialogo.h"

Dialogo::Dialogo(QWidget *parent) :
    QDialog(parent), buttonUpdate(0),
    ui(new Ui::Dialogo)
{
    ui->setupUi(this);
    connect(this->ui->buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),SLOT(slotCancelar()));
}

Dialogo::~Dialogo()
{
    delete ui;
}

//Publics slots
void Dialogo::setShowText(QString text)
{
    this->ui->textBrowser->setText(text);
}

void Dialogo::slotCancelar()
{
    this->hide();
    emit blockSignalsQTimer(false);//Vuelvo a activar la actualización de redes.
}

void Dialogo::setWindowCaption(QString title)
{
    this->setWindowTitle(title);
}

void Dialogo::setCancelText(QString text)
{
    this->ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(text);
}

void Dialogo::setOkText(QString)
{

}

void Dialogo::showDialog(bool show)
{
    if(show)
    {
        this->show();
    }
    else
    {
        this->hide();
    }
}

void Dialogo::removeButtonUpdate()
{
    if(buttonUpdate!=0){
        this->ui->buttonBox->removeButton(buttonUpdate); buttonUpdate=0;}
}

void Dialogo::addButton(QString texto, QDialogButtonBox::ButtonRole role)
{
    buttonUpdate = this->ui->buttonBox->addButton(texto,role);
    connect(this->buttonUpdate,SIGNAL(clicked()),SIGNAL(accepted()));
}
